<template>
  <div id="paper">
    <v-title title="项目管理周报"></v-title>

    <div class="btn-group">
      <v-condition :isMultiple="true" :isShow="true" :deliverCenterList='deliverCenterList'></v-condition>
      <el-dialog
          width="88%"
          title="周报详情"
          :visible.sync="showReport"
          class="dialog_body"
          destroy-on-close
          top='7vh'
          :close-on-click-modal='false'
          :close-on-press-escape='false'
      >
        <v-preview-report v-if='showReport' :multipleSelection='multipleSelection'/>
      </el-dialog>

      <div class='btnFilter'>
        <div class='itemNew'>
          <el-button
              @click="dialogVisibleWithoutConfirm = true"
              type="primary"
              size="large"
          >新增周报</el-button
          >
          <el-button
              @click="reportDisplay"
              type="primary"
              size="large"
          >
            预览所选项目周报
          </el-button>
        </div>
      </div>
    </div>

    <div class="table-box marT">
      <el-table
        ref="multipleTable"
        :border="true"
        :header-cell-style="{ background: '#42b1e8' }"
        :data="tables"
        style="width: 100%"
        :cell-style="backFun"
        v-loading="tableLoading"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
            type="selection"
            width="40">
        </el-table-column>
        <el-table-column label="事业部" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.dept_name }}</div>
          </template>
        </el-table-column>

        <el-table-column label="项目" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.project_name }}</div>
          </template>
        </el-table-column>

        <el-table-column label="工作周" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.week }}</div>
          </template>
        </el-table-column>

        <el-table-column label="项目风险自评" align="center">
          <template slot-scope="scope">
<!--            <div v-if="scope.row.risk_self_assessment === '低风险'">低风险</div>-->
<!--            <div v-else-if="scope.row.risk_self_assessment === '中风险'">-->
<!--              中风险-->
<!--            </div>-->
<!--            <div v-else-if="scope.row.risk_self_assessment === '高风险'">-->
<!--              高风险-->
<!--            </div>-->
<!--            <div v-else></div>-->
            <div>{{RiskSelfAssessment[scope.row.risk_self_assessment]}}</div>
          </template>
        </el-table-column>

        <el-table-column label="项目等级" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.project_level }}</div>
          </template>
        </el-table-column>

        <el-table-column label="主交付/产品中心" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.deliver_center }}</span>
          </template>
        </el-table-column>

        <el-table-column label="项目经理" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.pm }}</div>
          </template>
        </el-table-column>

        <el-table-column label="客户经理" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.am }}</div>
          </template>
        </el-table-column>

        <el-table-column label="更新时间" align="center">
          <template slot-scope="scope">
            <div>{{ scope.row.update_time }}</div>
          </template>
        </el-table-column>

        <el-table-column label="操作" align="center">
          <!-- <template slot-scope="scope"> -->
          <!-- <div v-if="scope.row.has_review && scope.row.week.split('第')[1].indexOf(theWeek()) > -1" class="toDetail" @click="toDetail(scope.row.report_id,1)">
              <span> 评审 </span>
            </div> -->
          <!-- <div v-else @click="toDetail(scope.row.report_id,0)" class="toDetail">
              <span> 查看 </span>
            </div>
            <div v-if="scope.row.week.split('第')[1].indexOf(theWeek()) > -1" class="toDetail" @click="toEditDetail(scope.row.report_id)" >编辑</div> -->

          <template slot-scope="scope">
            <div class="toDetail" @click="toDetail(scope.row)">查看</div>

            <div
              v-if="scope.row.week.split('第')[1].indexOf(theWeek()) > -1"
              class="toDetail"
              @click="toEditDetail(scope.row)"
            >
              编辑
            </div>
          </template>
          <!-- </template> -->
        </el-table-column>
      </el-table>

      <el-pagination
        class="marT"
        v-show="total > 10"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current"
        :page-size="size"
        layout="total, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>

    <!-- 查看 弹框 -->
    <el-dialog
      width="88%"
      title="项目管理周报详情"
      :visible.sync="dialogTableVisible"
      :close-on-click-modal='false'
      :close-on-press-escape='false'
      class="dialog_body"
    >
      <el-button
        v-if="isEdit"
        style="position: absolute; right: 58px; top: 19px; z-index: 9"
        @click="toSaveRes(currentId)"
        type="success"
        icon="el-icon-check"
        :loading="false"
        class="savebutton"
        >保存</el-button
      >
      <div class="upbutton">
        <el-upload
          v-if="isEdit"
          class="upload-demo"
          :action="urlLink"
          name="excel"
          ref="upLoadFile"
          :before-upload="beforeAvatarUpload"
          accept=".pdf, .doc, .docx, .xls, .xlsx, .png, .jpg, .JPG, .txt, .doc, .wps"
          :limit="999"
          multiple
          :on-error="erroring"
          :before-remove="beforeRemove"
          :on-success="handleSuccess"
          :on-remove="handleRemove"
          :file-list="fileList"
          :http-request="handUploadFile"
        >
          <el-button size="small" type="success">上传附件</el-button>
          <div
            slot="tip"
            class="el-upload__tip"
            style="font-size: 10px; color: red"
          >
            附件不超过15M
          </div>
        </el-upload>
      </div>
      <div id="CarDetails" v-if="Object.keys(inputObj).length">
        <div class="baseInfo marT">
          <el-divider content-position="left">项目基础信息</el-divider>
          <el-table
            :border="true"
            :header-cell-style="{ background: '#42b1e8' }"
            :data="inputObj.basic_info"
            style="width: 100%"
          >
            <el-table-column
              :label="item"
              align="center"
              v-for="item in list"
              :key="item"
            >
              <template slot-scope="scope">
                <div>{{ inputObj.basic_info[scope.$index][item] }}</div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <div class="total-condition marT">
          <el-divider content-position="left">项目总体状况</el-divider>

          <el-card shadow="always" class="flexing">
            <div class="left">
              <el-alert
                v-if="!isEdit"
                v-html="
                  inputObj.project_total_condition
                    ? textAreaTo(inputObj.project_total_condition)
                    : '暂无内容'
                "
                type="error"
                effect="dark"
                :closable="false"
              >
              </el-alert>
              <el-input
                v-else
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                placeholder="项目总体状况"
                v-model="inputObj.project_total_condition"
              >
              </el-input>
            </div>
            <div class="right">
              <label for="levels" style="margin: auto 15px">风险等级:</label>
              <template v-if="!isEdit">
                <span v-if="inputObj.risk_self_assessment === 1" class="low"
                  >低风险</span
                >
                <span
                  v-else-if="inputObj.risk_self_assessment === 2"
                  class="middle"
                  >中风险</span
                >
                <span v-else class="high">高风险</span>
              </template>
              <el-select
                v-else
                clearable
                v-model="inputObj.risk_self_assessment"
                placeholder="请选择风险等级"
              >
                <el-option
                  v-for="item in levelOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
          </el-card>
        </div>

        <div class="projectStatus">
          <el-divider content-position="left">项目状况</el-divider>
          <el-table
            :border="true"
            :header-cell-style="{ background: '#42b1e8' }"
            :data="inputObj.project_condition"
            style="width: 100%"
            :cell-style="backFun"
          >
            <el-table-column label="分类" align="center" width='150'>
              <template slot-scope="scope">
                <div>
                  {{ scope.row.risk_type }}
                </div>
              </template>
            </el-table-column>

            <el-table-column label="风险等级" align="center" width='150'>
              <template slot-scope="scope">
                <!-- <div v-if="scope.row.has_review"> -->

                <div v-if="typeof scope.row.risk_level == 'string'">
                  {{ scope.row.risk_level }}
                </div>
                <div v-else>
                  <div v-for="(v, k) in scope.row.risk_level" :key="k">
                    <span> {{ k }}</span> :
                    <span v-if="v === '低风险'" class="low"> {{ v }}</span>
                    <span v-else-if="v === '中风险'" class="middle">
                      {{ v }}
                    </span>
                    <span v-else-if="v === '高风险'" class="high">
                      {{ v }}
                    </span>
                    <span v-else> {{ v }} </span>  
                  </div>
                </div>
                <!-- </div> -->
              </template>
            </el-table-column>

            <el-table-column label="风险责任人" align="center" width='150'>
              <template slot-scope="scope">
                <div>
                  {{ scope.row.risk_owner }}
                </div>
              </template>
            </el-table-column>

            <el-table-column label="风险原因" align="center">
              <template slot-scope="scope">
                <div v-if="typeof scope.row.risk_level == 'string'">
                  {{ scope.row.risk_level }}
                </div>
                <div v-else>
                  <div v-for="(key, index) in Object.keys(scope.row.risk_reason)" :key="index">
                    {{ key }} :
                    {{ scope.row.risk_reason[key] }}
                    <el-divider v-if='Object.keys(scope.row.risk_reason).length - 1 !== index'/>
                  </div>
                </div>
              </template>
            </el-table-column>

            <el-table-column label="风险计划解决时间" align="center" width='150'>
              <template slot-scope="scope">
                <div v-if="!isEdit">
                  {{ scope.row.risk_solution_time }}
                </div>
                <div v-else>
                  <el-date-picker
                    v-model="scope.row.risk_solution_time"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </div>
              </template>
            </el-table-column>

            <el-table-column label="风险解决方案" align="center" width='150'>
              <template slot-scope="scope">
                <div
                  v-if="!isEdit"
                  v-html="scope.row.risk_handle_progress"
                  style="
                    text-align: left;
                    white-space: pre-wrap;
                    word-wrap: break-word;
                    word-break: break-all;
                  "
                ></div>
                <div v-else>
                  <el-input
                    type="textarea"
                    autosize
                    placeholder="请输入风险解决方案"
                    v-model="scope.row.risk_handle_progress"
                  >
                  </el-input>
                </div>
              </template>
            </el-table-column>

            <el-table-column
              label="风险解决层级"
              align="center"
              width='150'
            >
              <template slot-scope="scope">
                <div v-if="!isEdit">
                  <span v-if="scope.row.risk_solution_level === '1'">项目组内解决</span>
                  <span v-if="scope.row.risk_solution_level === '2'">事业部依赖</span>
                  <span v-if="scope.row.risk_solution_level === '3'">事业群依赖</span>
                  <span v-if="scope.row.risk_solution_level === '4'">客户部依赖</span>
                </div>
                <div v-else>
                  <el-select v-model="scope.row.risk_solution_level" placeholder="请选择" @change="chengeselectFn($event,scope.$index,scope.row)" clearable>
                  <el-option
                    v-for="item in optionsLevel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                    >
                  </el-option>
                </el-select>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <div class="high-light">
          <el-divider content-position="left">风险HighLight</el-divider>

          <!-- <div class="high-input">
            <b style="display: block; color: #999; margin-bottom: 10px"
              >Top1:</b
            >
            <el-alert
              v-if="!isEdit"
              v-html="
                inputObj.risk_highlight.risk_top_one
                  ? textAreaTo(inputObj.risk_highlight.risk_top_one)
                  : '暂无内容'
              "
              type="error"
              effect="dark"
              :closable="false"
            >
            </el-alert>
            <template v-else>
              <el-input
                v-if="inputObj.risk_highlight"
                type="textarea"
                autosize
                placeholder="TOP1"
                v-model="inputObj.risk_highlight.risk_top_one"
              >
              </el-input>
            </template>

            <b
              class="marT"
              style="display: block; color: #999; margin-bottom: 10px"
              >Top2:</b
            >
            <el-alert
              v-if="!isEdit"
              v-html="
                inputObj.risk_highlight.risk_top_two
                  ? textAreaTo(inputObj.risk_highlight.risk_top_two)
                  : '暂无内容'
              "
              type="error"
              effect="dark"
              :closable="false"
            >
            </el-alert>
            <template v-else>
              <el-input
                v-if="inputObj.risk_highlight"
                type="textarea"
                autosize
                placeholder="TOP2"
                v-model="inputObj.risk_highlight.risk_top_two"
              >
              </el-input>
            </template>

            <b
              class="marT"
              style="display: block; color: #999; margin-bottom: 10px"
              >Top3:</b
            >
            <el-alert
              v-if="!isEdit"
              v-html="
                inputObj.risk_highlight.risk_top_three
                  ? textAreaTo(inputObj.risk_highlight.risk_top_three)
                  : '暂无内容'
              "
              type="error"
              effect="dark"
              :closable="false"
            >
            </el-alert>
            <template v-else>
              <el-input
                v-if="inputObj.risk_highlight"
                type="textarea"
                autosize
                placeholder="TOP3"
                v-model="inputObj.risk_highlight.risk_top_three"
              >
              </el-input>
            </template>
          </div> -->
        <el-table
        :border="true"
        :header-cell-style="{background:'#42b1e8'}"
        :data="inputObj.risk_highlight"
        style="width: 100%"
        :cell-style="backFun"
      >
        <el-table-column
          label="Top级别"
          align="center"
          width='150'
        >
         <template slot-scope="scope">
           <div v-if="!isEdit">
              <span v-if="scope.row.top_level === '1'">Top1</span>
              <span v-if="scope.row.top_level === '2'">Top2</span>
              <span v-if="scope.row.top_level === '3'">Top3</span>
            </div>
            <div v-else>
               <el-select  v-model="scope.row.top_level" placeholder="请选择" @change="chengeselectFn1($event,scope.$index,scope.row)" clearable>
                <el-option
                  v-for="item in optionsTop"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
          </template>
        </el-table-column>

       <el-table-column
          label="风险描述"
          align="center"
        >
          <template slot-scope="scope">
            <div v-if="!isEdit" v-html="scope.row.risk"></div>
            <div v-else>
              <el-input
                type="textarea"
                autosize
                placeholder="风险描述"
                v-model="scope.row.risk">
              </el-input>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="风险责任人"
          align="center"
          width='150'
        >
          <template slot-scope="scope">
              <div v-if="!isEdit">
                {{ generate(scope.row.risk_owner).join(',') }}
              </div>
              <div v-else>
                <el-select
                  v-model="scope.row.ownerList"
                  multiple
                  filterable
                  remote
                  placeholder="请输入"
                  :remote-method="remoteMethod"
                  :loading="loading"
                  @blur="blur"
                  @change="change(scope.$index, $event)"
                  >
                  <el-option
                    v-for="item in options1"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                    >
                      <span style="float: left">{{ item.label }}</span>
                      <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                  </el-option>
                </el-select>
              </div>
            </template>
        </el-table-column>


        <el-table-column
          label="解决方案"
          align="center"
          width='150'
        >
          <template slot-scope="scope">
            <div v-if="!isEdit" v-html="scope.row.doc"></div>
            <div v-else>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入解决方案"
                v-model="scope.row.doc">
              </el-input>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="解决时间"
          align="center"
          width='150'
        >
          <template slot-scope="scope">
            <div v-if="!isEdit">
              {{ scope.row.time }}
            </div>
            <div v-else>
              <el-date-picker
                v-model="scope.row.time"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="解决层级"
          align="center"
          width='150'
        >
          <template slot-scope="scope">
            <div v-if="!isEdit">
              <div v-if="scope.row.level === '1'">项目组内解决</div>
              <div v-if="scope.row.level === '2'">事业部依赖</div>
              <div v-if="scope.row.level === '3'">事业群依赖</div>
              <div v-if="scope.row.level === '4'">客户部依赖</div>
            </div>
            <div v-else>
              <el-select v-model="scope.row.level" placeholder="请选择" @change="chengeselectFn($event,scope.$index,scope.row)" clearable>
                <el-option
                  v-for="item in optionsLevel"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  >
                </el-option>
            </el-select>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="风险状态"
          align="center"
          width='150'
        >
        <template slot-scope="scope">
            <div v-if="!isEdit">
              <div v-if="scope.row.status==='1'">关闭</div>
              <div v-if="scope.row.status==='2'">非关闭</div>
            </div>
            <el-select v-else v-model="scope.row.status" placeholder="请选择" @change="chengeselectFn2($event,scope.$index,scope.row)">
              <el-option
                v-for="item in optionsStatus"
                :key="item.value"
                :label="item.label"
                :value="item.value"
                >
              </el-option>
            </el-select>
          </template>
        </el-table-column>

      </el-table>
      <el-button
        type="primary"
        style="float: right; margin-top: 10px"
        @click="addFn()"
        v-if="isShow">
        新增
      </el-button>
        </div>

        <div class="now">
          <el-divider content-position="left">本周主要成果</el-divider>
          <el-alert
            v-if="!isEdit"
            type="success"
            :closable="false"
            v-html="
              inputObj.current_week_outcome
                ? textAreaTo(inputObj.current_week_outcome)
                : '暂无内容'
            "
          >
          </el-alert>
          <el-input
            v-else
            type="textarea"
            :autosize="{ minRows: 3, maxRows: 10 }"
            placeholder="本周主要成果"
            v-model="inputObj.current_week_outcome"
          >
          </el-input>
        </div>

        <div class="next">
          <el-divider content-position="left">下周工作计划</el-divider>
          <el-alert
            v-if="!isEdit"
            type="success"
            :closable="false"
            v-html="
              inputObj.next_week_plan
                ? textAreaTo(inputObj.next_week_plan)
                : '暂无内容'
            "
          >
          </el-alert>
          <el-input
            v-else
            type="textarea"
            :autosize="{ minRows: 3, maxRows: 10 }"
            placeholder="下周工作计划"
            v-model="inputObj.next_week_plan"
          >
          </el-input>
        </div>

        <div class="file">
          <el-divider content-position="left">周报附件</el-divider>
          <ul>
            <li v-for="(item, index) in inputObj.file_list" :key="index">
              <el-button @click="downloadSelection(item)">
                {{ item }}
              </el-button>
            </li>
          </ul>
        </div>

        <div class="review">
          <el-divider content-position="left">AM评审</el-divider>

          <el-input
            v-if="isEdit && showReview"
            type="textarea"
            :autosize="{ minRows: 3, maxRows: 10 }"
            placeholder="AM评审"
            v-model="inputObj.review"
          >
          </el-input>
          <el-alert
            v-else
            type="success"
            :closable="false"
            v-html="inputObj.review ? textAreaTo(inputObj.review) : '暂无内容'"
          >
          </el-alert>
        </div>

<!--        <div class="selfCheck">-->
<!--          <el-divider content-position="left">项目自检</el-divider>-->
<!--          <template >-->
<!--            <div style="margin-bottom: 10px; color:red">-->
<!--              {{inputObj.check_num}}-->
<!--            </div>-->
<!--          </template>-->
<!--            <el-table-->
<!--              :data="inputObj.check"-->
<!--              border-->
<!--              :header-cell-style="{ background: '#42B1E8' }"-->
<!--              style="margin-top: 20px"-->
<!--            >-->
<!--              <el-table-column property="num" label="编号" width="50" align="center">-->
<!--                <template slot-scope="scope">-->
<!--                   <div>{{ tableArr1[scope.$index]}}</div>-->
<!--                </template>-->
<!--              </el-table-column>-->

<!--              <el-table-column-->
<!--                label="检查项"-->
<!--                width="550"-->
<!--                align="center"-->
<!--              >-->
<!--                <template slot-scope="scope">-->
<!--                   <div>{{ tableArr3[scope.$index] }}</div>-->
<!--                </template>-->
<!--              </el-table-column>-->

<!--              <el-table-column-->
<!--                label="结果"-->
<!--                width="150"-->
<!--                align="center"-->
<!--              >-->
<!--                <template slot-scope="scope">-->
<!--                  <div>-->
<!--                     {{ scope.row[1].result }}  -->
<!--                  </div>-->
<!--                </template>-->
<!--              </el-table-column>-->

<!--              <el-table-column-->
<!--                label="说明"-->
<!--                width="300"-->
<!--                align="center"-->
<!--              >-->
<!--                <template slot-scope="scope">-->
<!--                  <div>-->
<!--                    {{ scope.row[1].explain}} -->
<!--                  </div>-->
<!--                </template>-->
<!--              </el-table-column>-->

<!--              <el-table-column-->
<!--                label="对策"-->
<!--                width="300"-->
<!--                align="center"-->
<!--              >-->
<!--                <template slot-scope="scope">-->
<!--                  <div>-->
<!--                    {{ scope.row[1].countermeasure }}-->
<!--                  </div>-->
<!--                </template>-->
<!--              </el-table-column>-->

<!--              <el-table-column label="解决时间" align="center" width="284">-->
<!--                <template slot-scope="scope">-->
<!--                  <div>-->
<!--                    {{ scope.row[1].fix_time }}-->
<!--                  </div>-->
<!--                </template>-->
<!--              </el-table-column>-->
<!--            </el-table>-->
<!--        </div>-->

      </div>
    </el-dialog>

    <!-- 自检弹框 -->
    <el-dialog width="88%" title="自检结果" :visible.sync="dialogTableVisible1">
      <div id="group">
        <el-row class="bgColor" style="float: left">
          <el-col :xs="24" :sm="24" :lg="24" class="toFlex">
            <div class="item">
              <label for="cascader">选择项目:</label>
               <el-cascader
                placeholder="请选择项目"
                :options="singleSelector"
                filterable
                :show-all-levels="false"
                @change="singleChange"
                style="margin-left: 10px"
                id="cascader"
              >
              </el-cascader>
            </div>
          </el-col>
        </el-row>
        <el-button type="primary" size="medium " style="float: right" @click="toSubmit()">提交</el-button>


      </div>
        <div class="warning" style="margin-top: 54px;">
           <el-alert
            title="请对项目周会实施情况进行自检，自检完成后，点击右上角【提交】，进入周报编辑页面"
            type="error"
            :closable="false">
           </el-alert>
        </div>
      <el-table
        :data="gridData"
        border
        :header-cell-style="{ background: '#42B1E8' }"
        style="margin-top: 7px"
      >
        <el-table-column property="num" label="编号" width="50" align="center">
        </el-table-column>

        <el-table-column
          property="checkList"
          label="检查项"
          width="550"
          align="center"
        >
        </el-table-column>

        <el-table-column
          property="address"
          label="结果"
          width="150"
          align="center"
        >
          <template slot-scope="scope">
            <el-select
              v-model="key.result[scope.$index]"
              placeholder="请选择"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </template>
        </el-table-column>

        <el-table-column
          property="date"
          label="说明"
          width="300"
          align="center"
        >
          <template slot-scope="scope">
            <!-- <div v-if="!isEdit" v-html="scope.row.risk_handle_progress"
          style="text-align: left;white-space: pre-wrap;word-wrap:break-word;word-break:break-all;"></div> -->
            <div>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入说明"
                v-model="key.explain[scope.$index]"
              >
              </el-input>
            </div>
          </template>
        </el-table-column>

        <el-table-column
          property="name"
          label="对策"
          width="300"
          align="center"
        >
          <template slot-scope="scope">
            <!-- <div v-if="!isEdit" v-html="scope.row.risk_handle_progress"
            style="text-align: left;white-space: pre-wrap;word-wrap:break-word;word-break:break-all;"></div> -->
            <div>
              <el-input
                type="textarea"
                autosize
                placeholder="请输入对策"
                v-model="key.countermeasure[scope.$index]"
                :rows="2"
              >
              </el-input>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="解决时间" align="center" width="284">
          <template slot-scope="scope">
            <div>
              <el-date-picker
                v-model="key.fix_time[scope.$index]"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

<!--    无确认信息新增周报-->
    <el-dialog
        :visible.sync="dialogVisibleWithoutConfirm"
        width="20%"
        title="选择项目"
        :append-to-body="true"
        :close-on-click-modal='false'
        :close-on-press-escape='false'
    >
      <el-form ref="numberValidateForm" label-width="100px">
        <el-form-item
            label="选择项目："
        >
          <el-cascader
              placeholder="请选择项目"
              :options="singleSelector"
              filterable
              :show-all-levels="false"
              @change="toDetailPage"
              style="margin-left: 10px"
          />
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import http from '@/views/sys/axios';
import VTitle from '@/views/sys/internetThings/title';
import VCondition from '@/views/data/carDispose/group';
import VPreviewReport from '@/views/data/carPaper/previewReport';
import { mapState, mapMutations } from 'vuex';
import { getHeader } from '@/app.config';

export default {
  name: 'carPaper',
  components: {
    VTitle,
    VCondition,
    VPreviewReport,
  },
  created() {

    this.conditionRes();
    this.initialDeliverCenterList()

  },
  data() {
    return {
      isShow:false,
      dialogVisibleWithoutConfirm:false,
      value1:[],
      deliverCenterList: [],
      disabledList:[],
      disabled:'',
      cache:[],
      loading: false,
      list1:'',
      options1:[],
      isChecked:false,
      optionsStatus:[
          {
            value: '1',
            label: '关闭',
          },
          {
            value: '2',
            label: '非关闭',
          },
        ],
      optionsTop:[
          {
            value: '1',
            label: 'Top1',
          },
          {
            value: '2',
            label: 'Top2',
          },
          {
            value: '3',
            label: 'Top3',
          },
        ],
      optionsLevel: [
        {
          value: '1',
          label: '项目组内解决',
        },
        {
          value: '2',
          label: '事业部依赖',
        },
        {
          value: '3',
          label: '事业群依赖',
        },
        {
          value: '4',
          label: '客户部依赖',
        },
      ],
      tableArr3:[],
      checkIndex:'',
      tableArr1:[1,2,3,4,5,6,7,8],
      tableArr2:[
        'PM是否按时组织实施了项目周会',
        'PM是否在项目管理看板更新了进度，成本等相关KPI，对项目进度，商务，成本等方面的风险做了说明与判断',
        '架构师，研发Leader是否在项目管理看板更新了技术领域KPI，对项目技术风险做了说明与判断',
        '测试Leader是否在项目管理看板更新了测试相关KPI，对项目质量风险做了说明与判断',
        '各领域负责人是否在周会上确认了当前阶段需要达成KPI目标和交付件的进展，并识别风险与问题向PM汇报，给出依赖与对策或建议',
        'PM是否基于项目管理看板填写结果，对当前阶段点各领域KPI目标的状况进行了跟踪与确认',
        'PM是否确认各领域的风险和课题，以及对策和依赖。协助各领域推动解决风险和课题',
        '是否按照阶段点计划，在周会上跟踪了阶段点实施的必要动作（建立任务，领域自检，问题对策与跟踪等）',
      ],
      resultVal:'',
      key: {
        result: [],
        explain: [],
        countermeasure: [],
        fix_time: [],
      },
      pjKey: '',
      pjId: [],
      singleSelected: null,
      singleSelector: [],
      data: [],
      // value1: '',
      options: [
        {
          value: 'OK',
          label: 'OK',
        },
        {
          value: 'NG',
          label: 'NG',
        },
      ],
      value: '',
      gridData: [
        {
          num: '1',
          checkList: 'PM是否按时组织实施了项目周会',
          address: '',
        },
        {
          num: '2',
          checkList:
            'PM是否在项目管理看板更新了进度，成本等相关KPI，对项目进度，商务，成本等方面的风险做了说明与判断',
          address: '',
        },
        {
          num: '3',
          checkList: '架构师，研发Leader是否在项目管理看板更新了技术领域KPI，对项目技术风险做了说明与判断',
          address: '',
        },
        {
          num: '4',
          checkList:
            '测试Leader是否在项目管理看板更新了测试相关KPI，对项目质量风险做了说明与判断',
          address: '',
        },
        {
          num: '5',
          checkList:
            '各领域负责人是否在周会上确认了当前阶段需要达成KPI目标和交付件的进展，并识别风险与问题向PM汇报，给出依赖与对策或建议',
          address: '',
        },
        {
          num: '6',
          checkList:
            'PM是否基于项目管理看板填写结果，对当前阶段点各领域KPI目标的状况进行了跟踪与确认',
          address: '',
        },
        {
          num: '7',
          checkList:
            'PM是否确认各领域的风险和课题，以及对策和依赖。协助各领域推动解决风险和课题',
          address: '',
        },
        {
          num: '8',
          checkList:
            '是否按照阶段点计划，在周会上跟踪了阶段点实施的必要动作（建立任务，领域自检，问题对策与跟踪等）',
          address: '',
        },
      ],

      dialogTableVisible1: false,
      dialogFormVisible: false,
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: '',
      },
      formLabelWidth: '120px',

      inputObjreview: '',
      reviewData: '',
      showReview: false,
      reportId: '',
      file: [],
      loadingbut: false,
      urlLink: '',
      fileList: [],
      tables: [],
      dialogTableVisible: false,
      inputObj: {},
      isEdit: false,
      currentId: '',
      status: 'look',
      current: 1,
      total: 0,
      size: 10,
      levelOptions: [
        {
          value: 3,
          label: '高风险',
        },
        {
          value: 2,
          label: '中风险',
        },
        {
          value: 1,
          label: '低风险',
        },
      ],
      RiskSelfAssessment: {
        1: '低风险',
        2: '中风险',
        3: '高风险',
      },
      tableLoading: false,
      showReport: false,
      multipleSelection: [],
    };
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      if (vm.dispose.projectIdList.length) {
        vm.tableLoading = true
        vm.getDataRes();
      }
    });
  },

  computed: {
    ...mapState({
      dispose: (state) => state.conditions.dispose,
      entryList: (state) => state.entryItem,
    }),
    list() {
      if (this.inputObj.basic_info && this.inputObj.basic_info.length) {
        return Object.keys(this.inputObj.basic_info[0]);
      }
    },
  },
  methods: {
    reportDisplay() {
      // const tmpvalueList = JSON.parse(localStorage.getItem('tmpvalueList'))
      // if (!tmpvalueList || !tmpvalueList.length) {
      //   this.$message.warning("请先选择项目后再进行周报预览")
      //   return
      // }
      this.showReport = true
    },
    change(index, val) {
        const obj = this.cache.filter(item => item.value === val[val.length - 1])
        const risk_owner = [...this.inputObj.risk_highlight[index].risk_owner, ...obj]
        this.$set(this.inputObj.risk_highlight[index], 'risk_owner', risk_owner)
      },
      generate(arr) {
        if(arr) {
          const list = arr.map(item => item.label)
          return list
        } else {
          return []
        }
      },
      blur() {
        this.options1 = []
      },
      async remoteMethod(query) {
        if (query !== '') {
          this.loading = true;
          this.options1 = []
          this.getStateResult(query)
        } else {
          this.options1 = [];
        }
      },
      getStates(name) {
        return http.get(`/api/account/user/query?name=${name}`)
      },
      async getStateResult(name) {
        try {
          const { code, user_list } = await this.getStates(name)
          if(code === 200) {
            this.loading = false
            this.options1 = user_list
            this.cache = user_list
          }
        } catch (err) {
          throw new Error(err)
        }
      },
      addFn(){
        let tmpVal = []
        this.inputObj.risk_highlight.push({

        })
        if(this.inputObj.risk_highlight.length >= 3 ) {
          this.isShow = false
        }
        console.log(this.inputObj.risk_highlight.length)
      },
      deleteRow(index, rows) {
        rows.splice(index, 1)
      },
      chengeselectFn2(e,index,row){
          if(e=='1'){
            this.value = ''
            this.value = '关闭'
            row.value  =  '关闭'
            this.isShow = true
            this.deleteRow(index,this.inputObj.risk_highlight)

          }else if(e == '2'){
            this.value = ''
            this.value = '非关闭'
            row.value  =  '非关闭'
          }
      },
      chengeselectFn1(e,index,row){
          if(e=='1'){
            this.value = ''
            this.value = 'Top1'
            row.value  =  'Top1'
            this.disabledList.push(this.value)
            // let tepList = this.disabledList.sort()
            // for(var i=0; i<this.disabledList.length;i++){
            //   if(tepList[i] == tepList[i+1] ){
            //     this.isChecked = true
            //     console.log("this.isChecked",this.isChecked)
            //   }
            // }
            let res = this.disabledList.findIndex((value,index,arr) =>{
              if(res === -1){
                return this.isChecked = true
              }
            })
            // console.log(777,res)

          }else if(e == '2'){
            this.value = ''
            this.value = 'Top2'
            row.value  =  'Top2'
            this.disabledList.push(this.value)
            // console.log(2,this.disabledList)
          }else if(e == '3'){
            this.value = ''
            this.value = 'Top3'
            row.value  =  'Top3'
            this.disabledList.push(this.value)
            // console.log(3,this.disabledList)
          }
        },
    chengeselectFn(e,index,row){
          if(e=='5'){
            this.value = ''
            this.value = '项目组内解决'
            row.value  =  '项目组内解决'
          }else if(e == '6'){
            this.value = ''
            this.value = '事业部依赖'
            row.value  =  '事业部依赖'
          }else if(e == '7'){
            this.value = ''
            this.value = '事业群依赖'
            row.value  =  '事业群依赖'
          }else if(e == '8'){
            this.value = ''
            this.value = '客户部依赖'
            row.value  =  '客户部依赖'
          }
        },
    submit(){
      let data = {}
      data.result = this.key.result
      data.explain = this.key.explain
      data.countermeasure = this.key.countermeasure
      data.fix_time = this.key.fix_time
      data.key = []
      let { result,explain,countermeasure,fix_time } = this.data

      this.key.result.map((item,index) =>{
        data.key.push({
          result:item,
          explain:data.explain[index],
          countermeasure:data.countermeasure[index],
          fix_time:data.fix_time[index]
        })
      })
      return  http.post(`/api/report/project/weekly/report/check?project_id=${this.pjId}`, data.key);
    },
    async toSubmit() {
      let data = {}
      data.result = this.key.result
      data.explain = this.key.explain
      data.countermeasure = this.key.countermeasure
      data.fix_time = this.key.fix_time
      data.key = []
      let { result,explain,countermeasure,fix_time } = this.data

      this.key.result.map((item,index) =>{
        data.key.push({
          result:item,
          explain:data.explain[index],
          countermeasure:data.countermeasure[index],
          fix_time:data.fix_time[index]
        })
      })
        let flag = true
        this.key.result.map((item,index) => {
          if(item == "NG") {
            flag = flag && this.key.explain[index] && this.key.fix_time[index]
          }
        })
        if( flag && data.key.length === 8 && this.pjId.length != 0){
          try{
            const { code, msg } = await this.submit()
            if( code === 200){
              this.dialogTableVisible1 = false
              this.status = 'edit';
              this.$router.push({
                path: '/car/ai-car/CarPaperDetails',
                query: {
                  status: this.status,
                },
              })
            }
          }catch (err){
            throw err
           }
        } else{
          this.$message({
              message: "请填写项目、所有结果和NG对策、解决时间",
              type: 'error',
          });
        }
    },
    toDetailPage(id) {
      this.pjId = id[2];
      localStorage.setItem('tmpProid',this.pjId)
      this.status = 'edit';
      this.$router.push({
        path: '/car/ai-car/CarPaperDetails',
        query: {
          status: this.status,
        },
      });
    },
    singleChange(id) {
      this.pjId = id[2];
      localStorage.setItem('tmpProid',this.pjId)
      http.get(`/api/report/project/weekly/report/check?project_id=${id[2]}`)
      .then((res)=>{
        const { res1,code } = res
        if(code === 200) {
          // this.showSelfcheck = res.is_show
          if( res.is_show ){
            this.dialogTableVisible1 = true
          }else{
            this.dialogTableVisible1 = false

            this.status = 'edit';
            this.$router.push({
              path: '/car/ai-car/CarPaperDetails',
              query: {
                status: this.status,
              },
            });
          }
        }
      })
    },
    condition() {
      return http.get(`/api/report/project/weekly/project/list`);
    },
    async conditionRes() {
      try {
        const { code, result } = await this.condition();

        if (code === 200) {
          this.singleSelector = result;
          const val1 = this.singleSelector[0].value;
          const val2 = this.singleSelector[0].children[0].value;
          const val3 = this.singleSelector[0].children[0].children[0].value;
          this.singleSelected = [val1, val2, val3];
          this.id = this.computeCondition(
            this.singleSelector,
            this.singleSelected
          );

        }
      } catch (err) {
        throw err;
      }
    },

    // 处理筛选条件数据
    computeCondition(list, filter) {
      if (Array.isArray(list) && !list.length) {
        return [];
      }
      const outer = list.filter((item) => item.value === filter[0]); // 事业群
      let mider = []; // 事业部
      let inner = []; // 项目

      if (outer[outer.length - 1].children) {
        let miderList = outer[outer.length - 1].children;
        mider = miderList.filter((item) => item.value === filter[1]);

        if (mider[mider.length - 1].children) {
          let innerList = mider[mider.length - 1].children;
          inner = innerList.filter((item) => item.value === filter[2]);
        }
      }
      const { value } = inner[0];
      return value;

    },
    // 上传
    async handUploadFile(content, data) {
      const { file } = content;
      let formData = new FormData();
      this.urlLink = `/api/report/project/weekly/report/data?projectId=${this.id}&week=${this.yearWeek}`;

      this.fileList.push(content.file);
      let list = this.fileList.map((v, i) => {
        return v.name;
      });
      this.fileData = {
        file_list: list,
      };
      formData.append('file', content.file);
      // this.fileData = data
      this.formData = formData;
    },
    handleSuccess(res) {
      if (res) {
        this.$message({
          message: res,
          type: 'success',
        });
      }
    },
    erroring(err) {
      if (err) {
        this.$message({
          message: err,
          type: 'error',
        });
      }
    },
    handleRemove(file, fileList) {
      this.inputObj.file_list = fileList.map((v, i) => {
        return v.name;
      });
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    beforeAvatarUpload(file) {
      const isLt15M = file.size / 1024 / 1024 < 15;
      this.fileStatus = true;
      if (!isLt15M) {
        this.$message({
          message: '导入的文件不能大于15M!',
          type: 'error',
        });
        this.fileStatus = false;
        return;
      }

      let name = file.name;
      let fileName = name.substring(name.lastIndexOf('.') + 1).toLowerCase();
    },
    // 下载
    downloadSelection(name) {
      this.loadingbut = true;
      this.loadingbuttext = '保存中...';
      http
        .get(
          `${process.env.VUE_APP_KANBAN_HOST}/api/report/project/weekly/report/file?file_name=${name}&report_id=${this.currentId}`,
          { responseType: 'blob' }
        )
        .then((res) => {
          const { data, status } = res;
          if (status === 200) {
            let blob = new Blob([data], { type: 'application/octet-stream' });
            const link = document.createElement('a');
            link.style.display = 'none';
            link.href = URL.createObjectURL(blob);
            link.setAttribute('download', name);
            document.body.appendChild(link);
            link.click();
            URL.revokeObjectURL(link.href);
            document.body.removeChild(link);
            this.loadingbut = false;
            this.loadingbuttext = '下载';
          } else {
            this.$message.error('下载出错了!');
          }
        })
        .catch((err) => {
          const { data } = err;

          if (data) {
            let blob = new Blob([data], { type: 'application/octet-stream' });
            const link = document.createElement('a');
            link.style.display = 'none';
            link.href = URL.createObjectURL(blob);
            link.setAttribute('download', name);
            document.body.appendChild(link);
            link.click();
            URL.revokeObjectURL(link.href);
            document.body.removeChild(link);
          } else {
            this.$message.error('下载出错了!');
          }
        });
    },
    backFun({ row, columnIndex }) {
      if (row.hasOwnProperty('risk_self_assessment')) {
        if (columnIndex === 3) {
          if (row.risk_self_assessment === 1) {
            return 'background: #67c23a;color: #fff';
          } else if (row.risk_self_assessment === 2) {
            return 'background: #e6a23c;color: #fff';
          } else if (row.risk_self_assessment === 3) {
            return 'background: #e4393c;color: #fff';
          }
        }
      } else {
        if (columnIndex === 1) {
          if (row.risk_level && row.risk_level === '低风险') {
            return 'background: #67c23a;color: #fff';
          } else if (row.risk_level && row.risk_level === '中风险') {
            return 'background: #e6a23c;color: #fff';
          } else if (row.risk_level && row.risk_level === '高风险') {
            return 'background: #e4393c;color: #fff';
          }
        }
      }
    },
    handleCurrentChange(val) {
      this.current = val;
      this.tableLoading = true
      this.getDataRes();
    },
    handleSizeChange(val) {
      this.size = val;
    },
    theWeek() {
      let now = new Date();
      let a = now.getFullYear();
      let b = now.getMonth();
      let c = now.getDate();
      let date1 = new Date(a, b, c),
        date2 = new Date(a, 0, 1),
        d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
      // console.log('week',Math.ceil((d + ((date2.getDay() + 1) - 1)) / 7))
      return Math.ceil((d + (date2.getDay() + 1 - 1)) / 7);
    },
    textAreaTo(str) {
      let regs = new RegExp('\r', 'g');
      let reg = new RegExp('\n', 'g');
      str = str.replace(reg, '<br/>');
      str = str.replace(regs, '<br/>');
      return str;
    },
    getData() {
      const projectSearch = this.dispose.projectIdList.length < this.dispose.oriProjectIDList.length
      let data = {projectSearch};
      data.projects = this.dispose.projectIdList;
      data.week = this.dispose.weeks;
      data.risk_level = this.dispose.levels;
      data.project_level = this.dispose.project_level;
      data.deliver_center = this.dispose.deliver_center;
      return http.post(
        `/api/report/project/weekly/report/list?page=${this.current}`,
        data
      );
    },
    async getDataRes() {
      try {
        const { code, data, count } = await this.getData();
        if (code === 200) {
          this.tables = data;
          this.total = count || 0;
          this.tableLoading = false
        }
      } catch (err) {
        throw err;
      }
    },
    async toDetail(row) {
      this.dialogTableVisible = true;
      this.showReview = row.has_review;
      this.isEdit = false;
      this.currentId = row.report_id;
      try {
        const { code, data } = await this.initDetail([row.report_id]);
        if (code === 200) {
          // console.log(333,this.inputObj)
          if (data.length) {
            this.inputObj = data[0];
            this.reviewData = data[0].review;
            // this.list1 =
            data[0].check.map((v,i) => {
              this.checkIndex = v[0]
              this.tableArr3.push(this.tableArr2[this.checkIndex])
            })
          } else {
            this.$message.warning("未查询到周报详情")
          }

        }
      } catch (err) {
        throw err;
      }
    },
    toEditDetail(row) {
      this.dialogTableVisible = true;
      // this.getStateResult()
      this.showReview = row.has_review;
      this.isEdit = true;
      this.currentId = row.report_id;
      this.initRes(row.report_id);
    },
    initDetail(idList) {
      const data = {
        report_id: idList,
        isReportIDList: true
      }
      return http.post(`/api/report/project/weekly/detail`, data);
    },
    toSave(id) {
      let formData = this.formData;
      let data = {};
      this.reviewData = this.inputObj.review;
      const obj = this.inputObj;

      let projectConditionCanContinue = true
      let projectRiskHighLightCanContinue = true
      const project_condition = obj.project_condition
      project_condition.forEach(async item => {
        // const riskLevelList = Object.keys(item.risk_level).map(key => item.risk_level[key])
        const riskText = item.risk_level[`${Object.keys(item.risk_level)[0]}`]
        if (riskText === '中风险' || riskText === '高风险') {
          if (!item.risk_solution_time) {
            projectConditionCanContinue = false
            await this.$message.warning('项目状况：风险等级中、高风险必须填写风险计划解决时间')
          }
          if (!item.risk_handle_progress) {
            projectConditionCanContinue = false
            await this.$message.warning('项目状况：风险等级中、高风险必须填写风险解决方案')
          }
          if (!item.risk_solution_level) {
            projectConditionCanContinue = false
            await this.$message.warning('项目状况：风险等级中、高风险必须选择风险解决层级')
          }
        }
      })
      if (!projectConditionCanContinue) {
        this.isDisabled = false
        return
      }

      this.inputObj.risk_highlight.forEach(async item => {
         if(!item.risk_owner){item.risk_owner = []}
         item.risk_owner = item.risk_owner.filter(ow => {
          const index = item.ownerList.findIndex(idx => ow.label == idx || ow.value == idx)
            if(index == -1) {
              return false
            }
            return true
        })

        if (item.risk) {
          if (!item.ownerList.length) {
            projectRiskHighLightCanContinue = false
            await this.$message.warning('风险HighLight：请选择风险责任人')
          }
          if (!item.doc) {
            projectRiskHighLightCanContinue = false
            await this.$message.warning('风险HighLight：请输入风险解决方案')
          }
          if (!item.time) {
            projectRiskHighLightCanContinue = false
            await this.$message.warning('风险HighLight：请选择解决时间')
          }
          if (!item.level) {
            projectRiskHighLightCanContinue = false
            await this.$message.warning('风险HighLight：请选择解决层级')
          }
          if (!item.status) {
            projectRiskHighLightCanContinue = false
            await this.$message.warning('风险HighLight：请选择风险状态')
          }
        }
      })

      if (!projectRiskHighLightCanContinue) {
        this.isDisabled = false
        return
      }
      Object.keys(obj).forEach((item) => {
        if (item === 'basic_info') {
          delete obj[item];
        }
      });
      if (!formData) {
        formData = new FormData();
      }
      data = Object.assign(obj, this.fileData);
      formData.append('data', JSON.stringify(data));
      return http.post(
        `api/report/project/weekly/${id}/change/?review=${this.reviewData}`,
        formData
      );
    },
    async toSaveRes(id) {
      this.loadingbut = true
      this.loadingbuttext = '...';
      if (this.showReview) {
        if (this.inputObj.review == '') {
          this.$message({
            message: 'AM评审未填写',
            type: 'error',
          });
          return false;
        }
      }

      try {
        const { code, msg } = await this.toSave(id);
        if (code === 200) {
          this.dialogTableVisible = false;
          this.$router.push({
            path: '/car/ai-car/car-paper',
          }),
            this.$message({
              message: '保存成功',
              type: 'success',
            });
        } else {
          this.$message({
            message: '保存失败',
            type: 'error',
          });
        }
      } catch (err) {
        throw err;
      }
      //  window.location.reload();
    },
    init(id) {
      return http.get(`/api/report/project/weekly/${id}/change/`);
    },
    async initRes(id) {
      try {
        const { code, data } = await this.init(id);
        if (code === 200) {
          this.inputObj = data;
          if(this.inputObj.risk_highlight.length < 3) {
              this.isShow = true
          } else{
            this.isShow = false
          }
          this.inputObj.risk_highlight = this.inputObj.risk_highlight.map(item => {
            if(!item.risk_owner) {item.risk_owner = []}
            const ownerList = item.risk_owner.map(ow => ow.label)
            // console.log("ownerList",ownerList)
            return{
              ...item,
                ownerList
            }
          })
          this.fileList = data.file_list.map((item) => {
            return {
              name: item,
              url: '/api/report/project/weekly/report/file' + item,
            };
          });

          data.check.map((v,i) => {
            this.checkIndex = v[0]
            this.tableArr3.push(this.tableArr2[this.checkIndex])
          })
        }
      } catch (err) {
        throw err;
      }
    },
    edit() {
      // if(!ids.length) {
      //   this.$message.error('请先选择项目!');
      //   return
      // }
      this.status = 'edit';
      this.$router.push({
        path: '/car/ai-car/CarPaperDetails',
        query: {
          status: this.status,
        },       
      });
    },
    async initialDeliverCenterList() {
      const {success, data} = await this.getDeliverCenterList()
      if (success) {
        this.deliverCenterList = data.map(item => {
          return {
            label: item.core_name,
            value: item.core_name,
          }
        })
      }
    },
    getDeliverCenterList() {
      return http.get(`/api/report/project/weekly/report/deliver_center`)
    },
    handleSelectionChange(selected_val) {
      this.multipleSelection = selected_val.map(item => item.report_id)
    }
  },
  watch: {
    dispose: {
      handler: function (newVal) {
        if (this.dispose.projectIdList.length) {
          this.tableLoading = true
          this.getDataRes();
        } else {
          this.dispose.projectIdList = this.dispose.oriProjectIDList.map(item => item[2])
          this.tableLoading = true
          this.getDataRes();
        }
      },
      deep: true,
    },
    dialogTableVisible(newVal) {
      if (!newVal) {
        this.inputObj = {};
        this.currentId = '';
        this.tableLoading = true
        this.getDataRes();
      }
    },
  },
};
</script>

<style lang="scss" scoped>
// @import url("../../../styles/dis.scss");
/deep/.el-alert__title {
    font-size: 14px !important
}
/deep/ .el-table th.gutter {
  display: table-cell !important;
}
/deep/ .el-table colgroup.gutter {
  display: table-cell !important;
}
// .upload-demo{
//   position: absolute;
//   right: 170px;
//   top: 37px;
//   z-index: 9;

// }

.reviewSave {
  margin-left: 95%;
  margin-top: 14px;
}
.savebutton {
  z-index: 99990000;
  top: 20px;
}
.upbutton {
  position: absolute;
  right: 88px;
  top: 20px;
  width: 200px;
  overflow: hidden;
  height: 200px;
  z-index: 1;
}
#paper {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;
  .btn-group {
    position: relative;
    .edit {
      position: absolute;
      top: 25%;
      right: -3.4%;
      width: 10em;
      transform: translate(-50%, -50%);
    }
    .readReport {
      position: absolute;
      top: 70%;
      width: 10em;
      right: -3.4%;
      transform: translate(-50%, -50%);
    }
  }
}
/deep/ .el-table thead {
  color: #fff;
}
.marT {
  margin-top: 20px;
}
.high {
  color: #e4393c;
}
.middle {
  color: #e6a23c;
}
.low {
  color: #67c23a;
}
.toDetail {
  cursor: pointer;
}
#CarDetails {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;
}
/deep/ .el-card__body {
  display: flex;
  .left {
    width: 85%;
    margin: auto 0;
  }
  .right {
    flex: 1;
    margin: auto 0;
  }
}
/deep/ .el-alert {
  line-height: 28px;
  font-size: 18px;
}
/deep/ .el-alert__title {
  font-size: 16px;
  line-height: 24px;
}
/deep/ .el-alert__description {
  font-size: 16px;
  line-height: 24px;
}
/deep/ .el-table th.gutter {
  display: table-cell !important;
}
/deep/ .el-table colgroup.gutter {
  display: table-cell !important;
}
/deep/ .el-table thead {
  color: #fff;
}
/deep/ .el-divider__text {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  background-color: #e6a23c;
  padding: 6px 16px;
}
/deep/ .el-divider--horizontal {
  margin: 40px 0;
  height: 2px;
}
.btnFilter {
  background: #ffffff;
  display: flow-root;
  .itemNew {
    padding-bottom: .5%;
    float: right;
    margin-right: .5%;
  }
}
</style>
